<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-md-2">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>{$page_title}</h5>
                    <div class="ibox-tools"><a class="refresh-tree">{:lang('刷新')}</a></div>
                </div>
                <div class="ibox-content no-padding right_centent" style="">
                    <div id="left-tree" data-url="{:url('TenMenu/get_list_tree')}"></div>
                </div>
            </div>
        </div>
        <div class="col-md-10">
            <div class="ibox float-e-margins">
                <div class="ibox-title">{$page_title}</div>
                <div class="ibox-content">
                    <div class="row">
                        <form id="pagerForm" method="post" class="form-inline searchForm">
                            <input type="hidden" name="pid" value="">
                            <div class="col-sm-6 m-b-xs">
                                <a class="btn btn-warning refresh-tree"> <i class="fa  fa-reply-all"> </i>{:lang('返回')}</a>
                                <lqf_link>
                                    <a class="btn btn-info ajax-open add-btn" data-url="{:url('TenMenu/add')}">
                                        <i class="fa fa-plus"></i>{:lang('添加')}
                                    </a>
                                </lqf_link>
                                <div class="btn-group">
                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
                                        <i class="fa fa-edit"></i> {:lang('批量操作')}<span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu">
                                        <lqf_link>
                                            <li><a data-url="{:url('TenMenu/move')}" class="ajax-open-more">{:lang('批量移动')}</a>
                                            </li>
                                        </lqf_link>
                                        <lqf_link>
                                            <li><a data-url="{:url('TenMenu/copy')}" class="ajax-open-more">{:lang('批量复制')}</a>
                                            </li>
                                        </lqf_link>
                                        <li class="divider"></li>
                                        <lqf_link>
                                            <li><a data-url="{:url('TenMenu/import')}"
                                                   class="ajax-open">{:lang('导入菜单')}</a></li>
                                        </lqf_link>
                                        <lqf_link>
                                            <li><a data-url="{:url('TenMenu/export')}"
                                                   class="ajax-open">{:lang('导出菜单')}</a></li>
                                        </lqf_link>
                                        <li class="divider"></li>
                                        <lqf_link>
                                            <li><a data-url="{:url('TenMenu/del')}" class="ajax-get-more text-danger">{:lang('批量删除')}</a>
                                            </li>
                                        </lqf_link>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-sm-6 m-b-xs text-right">
                                <div class="input-group">
                                    <input type="text" name="keywords" placeholder="{:lang('enter keyword search')}"
                                           class="form-control">
                                </div>
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-primary ajaxSearchForm"><i
                                                class="fa fa-search"></i> {:lang('搜索')}</button>
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="table table-hover sorttable ajax-list-table" data-url="{:url('TenMenu/show_json')}" width="100%">
                        <thead>
                        <tr>
                            <th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                            <th width="60">{:lang('编号')}</th>
                            <th width="100">{:lang('菜单名称')}</th>
                            <th width="80">{:lang('菜单图标')}</th>
                            <th width="200">{:lang('菜单地址')}</th>
                            <th width="100">{:lang('模块名')}</th>
                            <th width="80">{:lang('排序')}</th>
                            <th width="60" class="text-center">{:lang('菜单')}</th>
                            <th width="60" class="text-center">{:lang('启用')}</th>
                            <th width="120" class="text-center">{:lang('操作')}</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        <tfoot class="ibox-content">
                        <tr>
                            <td colspan="8" align="center"></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<link href="__STATIC__/module/admin/js/plugins/bootstrap-treeview/bootstrap-treeview.min.css" rel="stylesheet">
<script src="__STATIC__/module/admin/js/plugins/bootstrap-treeview/bootstrap-treeview.js"></script>

<script id="tableListTpl" type="text/html">
    <% for(var i=0;i<data.length;i++) {
        visible='';if(data[i]['visible']=='1') visible='checked';
        is_menu='';if(data[i]['is_menu']=='1') is_menu='checked';
    %>
    <tr>
        <td><input name="id" class="checkboxCtrlId" value="<%=data[i]['id']%>" type="checkbox"></td>
        <td><%=data[i]['id']%></td>
        <td>
            <input type="text" name="name" value="<%=data[i]['name']%>" class="form-control ajax-field"
                   data-url="{:url('TenMenu/set_field',array('name'=>'name'))}" data-id="<%=data[i]['id']%>" size="10">
        </td>
        <td>
            <input type="text" name="icon" value="<%=data[i]['icon']%>" class="form-control ajax-field"
                   data-url="{:url('TenMenu/set_field',array('name'=>'icon'))}" data-id="<%=data[i]['id']%>" size="10">
        </td>
        <td>
            <input type="text" name="url" value="<%=data[i]['url']%>" class="form-control ajax-field"
                   data-url="{:url('TenMenu/set_field',array('name'=>'url'))}" data-id="<%=data[i]['id']%>" size="10">
        </td>
        </td>
        <td>
            <input type="text" name="module" value="<%=data[i]['module']%>" class="form-control ajax-field"
                   data-url="{:url('TenMenu/set_field',array('name'=>'module'))}" data-id="<%=data[i]['id']%>"
                   size="10">
        </td>
        <td><input type="text" name="sort" value="<%=data[i]['sort']%>" class="form-control ajax-sort"
                   data-url="{:url('TenMenu/set_sort',array('name'=>'sort'))}" data-id="<%=data[i]['id']%>" size="5">
        </td>
        <td class="text-center">
            <input name="visible" class="ajax-checkbox" type="checkbox"
                   data-url="{:url('TenMenu/set_visible',array('name'=>'is_menu'))}" data-id="<%=data[i]['id']%>"
            <%=is_menu%> >
        </td>
        <td class="text-center">
            <input name="visible" class="ajax-checkbox" type="checkbox"
                   data-url="{:url('TenMenu/set_visible',array('name'=>'visible'))}" data-id="<%=data[i]['id']%>"
            <%=visible%> >
        </td>
        <td class="text-center">
            <lqf_link><a href="javascript:void(0)" class="get-son-list" data-id="<%=data[i]['id']%>">{:lang('下级')}</a>
            </lqf_link>
            <lqf_link><a class="ajax-get" data-url="{:url('TenMenu/copy_one')}" data-ids="{'id':'<%=data[i]['id']%>'}">{:lang('复制')}</a>
            </lqf_link>
            <lqf_link><a class="ajax-open" data-url="{:url('TenMenu/edit')}" data-ids="{'id':'<%=data[i]['id']%>'}">{:lang('修改')}</a>
            </lqf_link>
            <lqf_link><a class="ajax-del confirm" data-url="{:url('TenMenu/del')}"
                         data-ids="{'id':'<%=data[i]['id']%>'}">{:lang('删除')}</a></lqf_link>
        </td>
    </tr>
    <% } %>
</script>
<script type="text/javascript">
    $(document).ready(function () {
        //BindEvent();
        window.onload = onLoad();
        function onLoad() {
            $('.searchForm').find("input[name='pid']").val('');
            var target = $('#left-tree').attr('data-url');
            $.get(target).success(function (jsonData) {
                $('#left-tree').treeview({
                    data: jsonData,
                    levels: 1,
                    showTags: false,
                    showCheckbox: false,
                    multiSelect: false,
                    showBorder: false,
                    onNodeSelected: function (event, node) {
                        $('.searchForm').find("input[name='pid']").val(node.id);
                        $('.add-btn').attr('data-id', node.id);
                        turnPage(1);
                    }
                });
            }, "json");
            turnPage(1);
        }

        $("body").on("click", ".refresh-tree", function () {
            onLoad();
            turnPage(1);
        });
        //点击下级
        $("body").on("click", ".get-son-list", function () {
            var pid = $(this).attr('data-id');
            $('.searchForm').find("input[name='pid']").val(pid);
            $('.add-btn').attr('data-id', pid);
            turnPage(1);
        });
    });
</script>